package com.pwt.controller.basicsetting;

import com.pwt.annotation.Update;
import com.pwt.common.ResultPage;
import com.pwt.entity.AcceptanceHand;
import com.pwt.entity.AcceptanceLimit;
import com.pwt.model.ComboBoxModel;
import com.pwt.service.AcceptanceHandService;
import com.pwt.service.AcceptanceLimitService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/9/29
 */
@RestController
@Tag(name = "控制线配置")
public class AcceptanceLimitController {

    private AcceptanceLimitService acceptanceLimitService;

    private AcceptanceHandService acceptanceHandService;

    public AcceptanceLimitController(AcceptanceLimitService acceptanceLimitService, AcceptanceHandService acceptanceHandService) {
        this.acceptanceLimitService = acceptanceLimitService;
        this.acceptanceHandService = acceptanceHandService;
    }
    @Hidden
    @GetMapping("/acceptance-type")
    @Operation(description = "获取公式",summary = "获取公式类型")
    public List<ComboBoxModel> getType(){
       return this.acceptanceLimitService.getType();
    }
    @Hidden
    @GetMapping("/acceptance-page")
    @Operation(description = "列表查询",summary = "列表查询")
    @Parameters({
            @Parameter(name = "page",description = "当前页"),
            @Parameter(name = "limit",description = "每页展示数")
    })
    public ResultPage<AcceptanceLimit> getPage(Integer page, Integer limit){
        return this.acceptanceLimitService.getPage(page,limit);
    }
    @Hidden
    @PostMapping("/acceptance")
    @Operation(description = "新增",summary = "新增")
    public AcceptanceLimit add(@RequestBody AcceptanceLimit acceptanceLimit){
        return this.acceptanceLimitService.add(acceptanceLimit);
    }

    @Hidden
    @PutMapping("/acceptance")
    @Operation(description = "修改",summary = "修改")
    public AcceptanceLimit update(@RequestBody @Validated(Update.class) AcceptanceLimit acceptanceLimit){
        return this.acceptanceLimitService.add(acceptanceLimit);
    }

    @Hidden
    @DeleteMapping("/id")
    @Operation(description = "删除",summary = "删除")
    @Parameters({
            @Parameter(name = "id",description = "主键id")
    })
    public void delete(String id){
        this.acceptanceLimitService.delete(id);
    }
    @Hidden
    @PostMapping("/acceptance-hand")
    @Operation(description = "手动添加控制限",summary = "手动添加控制限")
    public AcceptanceHand  handSetting(@RequestBody AcceptanceHand acceptance){
        return this.acceptanceHandService.setting(acceptance);
    }




}
